home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.AWTEvent;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.InputEvent;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
-
- class Autoscroller extends MouseAdapter implements Serializable {
- transient MouseEvent event;
- transient Timer timer;
- JComponent component;
-
- Autoscroller(JComponent var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("component must be non null");
- } else {
- this.component = var1;
- this.timer = new Timer(100, new AutoScrollTimerAction(this));
- this.component.addMouseListener(this);
- }
- }
-
- void dispose() {
- this.stop();
- this.component.removeMouseListener(this);
- }
-
- public void mouseDragged(MouseEvent var1) {
- Rectangle var2 = this.component.getVisibleRect();
- boolean var3 = var2.contains(var1.getX(), var1.getY());
- if (var3) {
- if (this.timer.isRunning()) {
- this.stop();
- }
- } else {
- Point var4 = this.component.getLocationOnScreen();
- this.event = new MouseEvent(this.component, ((AWTEvent)var1).getID(), ((InputEvent)var1).getWhen(), ((InputEvent)var1).getModifiers(), var1.getX() + var4.x, var1.getY() + var4.y, var1.getClickCount(), var1.isPopupTrigger());
- if (!this.timer.isRunning()) {
- this.timer.start();
- }
- }
-
- }
-
- public void mouseReleased(MouseEvent var1) {
- this.stop();
- }
-
- private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- this.timer = new Timer(100, new AutoScrollTimerAction(this));
- }
-
- void stop() {
- this.timer.stop();
- this.event = null;
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- }
- }
-